// routes/bannerRoutes.js
const express = require('express');
const router = express.Router();
const bannerController = require('../controllers/bannerController');
const authenticateToken = require('../middleware/auth');
const upload = require('../middleware/upload'); // 引入上传中间件

// 公共路由
router.get('/', bannerController.getAllBanners);
router.get('/:id', bannerController.getBannerById);

// 管理员路由（需要认证）
router.post('/', authenticateToken, upload.single('image'), bannerController.createBanner);
router.put('/:id', authenticateToken, upload.single('image'), bannerController.updateBanner);
router.delete('/:id', authenticateToken, bannerController.deleteBanner);

module.exports = router;